package com.dji.custom.service;

import com.dji.sample.manage.model.dto.DeviceDTO;
import com.dji.sdk.cloudapi.device.OsdRcDrone;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class CustomService {

    @Autowired
    protected ObjectMapper mapper;

    @Autowired
    private IExpandMediaFileService expandMediaFileService;

    @Autowired
    private IExpandWaylinePointService expandWaylinePointService;

    @Autowired
    private IExpandWaylineFileService expandWaylineFileService;


    // 添加航线拓展表的mqtt方法
    public void waylineInsertCustom(String waylineId, String objectKey) {
        try {
            expandWaylineFileService.insertExpandWaylineFileCustom(waylineId, objectKey);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 删除航线拓展表的mqtt方法
    public void waylineDeleteCustom(String waylineId) {
        try {
            expandWaylineFileService.deleteExpandWaylineFileCustom(waylineId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 记录飞机实时经纬度的mqtt方法
    public void osdInfoInsertCustom(DeviceDTO device, OsdRcDrone data) {
        try {
            expandWaylinePointService.insertExpandWaylinePointCustom(device,data);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 开启直播新增录像信息的mqtt方法
    public void liveVideoInsertCustom(String liveUrlStream, String rtmpUrl, String deviceSn, String deviceName,
                                       String jobId, String waylineId) {
        try {
            expandMediaFileService.insertExpandMediaCustom(liveUrlStream, rtmpUrl, deviceSn, deviceName, jobId, waylineId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
